package com.jin.lazytool;

import com.jin.lazytool.utils.LogUtil;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.io.IOException;

public class JinTaskApplication extends Application {

    private static volatile  boolean isRunning = false;

    public static Stage STAGE ;
    @Override
    public void start(Stage stage) throws IOException {
        if(isRunning){
            return;
        }
        isRunning = true;
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("aaa.fxml"));
        Scene scene = new Scene(fxmlLoader.load(), 800, 600);

        stage.setTitle("鼠标键盘工具!");
        stage.getIcons().add(new Image("jinTask.png"));
        stage.setScene(scene);
        stage.setOnCloseRequest(windowEvent -> {
            Platform.exit();
            System.exit(0);
        });


        stage.show();
        STAGE = stage;
        JinTaskController.controller.refreshTaskClick(null);
    }


    public static void main(String[] args) {
        // 捕捉未处理的异常
        Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
            // 抛出栈信息
            LogUtil.error("未知异常",e);
        });
        launch();

    }

}